<template>
	<div class="container">
	<el-form :model="ruleForm" ref="ruleForm"  :rules = "rules" :label-position="labelPosition" label-width="120px" class="demo-ruleForm">

	    <div class="container" style="margin-top:20px;">
			<h3 v-if="id==undefined">新增员工</h3>
			<h3 v-else>编辑</h3>
	        <el-row style="margin-top:20px;">
				<el-col :span="12">
					<el-form-item label="员工名称：" prop="name">
					    <el-input placeholder="请输入内容" v-model="ruleForm.name" style="width: 300px"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="10">
					<el-form-item label="联系方式：" prop="phone">
					    <el-input placeholder="请输入内容" v-model="ruleForm.phone" style="width: 300px"></el-input>
					</el-form-item>
				</el-col>
			</el-row>
	    </div>
	    <el-form-item class="footerFixed" label-width="0px">
	        <el-button type="primary" @click="submitrule('ruleForm')">提交</el-button>
	        <el-button @click="backPage">返回</el-button>
	    </el-form-item>
	</el-form>
	</div>
</template>

<script>
	import axios from "axios"
	export default{
		data(){
			return{
				ruleForm:{},
				rules:{},
				labelPosition:"right"
			}
		},
		created(){
			this.id = this.$route.query.id
		   // if(this.id == undefined){

		   // }else{
		       // this.init()
		   // }
		   if(this.id == undefined){

		   }else{
			   this.init()
		   }
		},
		methods:{
			init(){
				axios.get("http://47.108.220.160:90/jcApi/plant/control/storeHouse/findManById?id="+this.id).then(res=>{
					this.ruleForm = res.data.data
				})
			},
			submitrule(){
				let data = this.ruleForm
				axios.post("http://47.108.220.160:90/jcApi/plant/control/storeHouse/storeMan",data).then(res=>{
					this.$notify({
					    title: '提示',
					    message: '保存成功',
					    type: 'success',
					    duration: 1000
					});
					this.backPage()
				})
			},
			// 返回上一页
			 backPage () {
			     this.$router.go(-1);
			 },
		}
	}
</script>

<style scoped>

</style>
